package com.tiamo.traders.controller.controllerFont;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tiamo.traders.entity.Business;
import com.tiamo.traders.servicefront.FrontBusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@RestController
@RequestMapping("")
public class FrontBusinessController {
    @Autowired
    FrontBusinessService businessService;
    @RequestMapping("/frontBusinessById")
    public List<Business> businessFindById(Business business) {
//        PageHelper.startPage(business.getPageNo(),business.getPageSize());
//        PageInfo<Business> pageInfo=new PageInfo<>(businessService.businessFindById(business));
//        System.out.println(pageInfo.getTotal());
        List<Business> businessList=businessService.businessFindById(business);
        return businessList;
    }


    public int getCount(Business business) {
        return businessService.getCount(business);
    }

    @RequestMapping("/business")
    public PageInfo<Business> findAll(Business business) {
        PageHelper.startPage(business.getPageNo(),business.getPageSize());
        PageInfo<Business> pageInfo=new PageInfo<>(businessService.findAll(business));
        return pageInfo;
    }
}
